<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * create adminedotorpage
 * get: admin.editor.tpl.php
 * used from admin.page.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
$refPage->assign('pageTitel', _('Entry editor'));

// create admin-editor
$datax = $refValidate->testText($_GET['name'], _('Adminname'), 3, 64);
db::getInstance()->where('user_name', $datax);
$admin = db::getInstance()->getOne('user');

if ($admin === NULL)
{ // No entry...
	message::setErrorRow(_('Entry not found') . ' -> ' . $datax, true);
}
else
{
	$refPage->assign('formStart', 'index2.php?page=' . $page . '&sub=' . $subpage . '&func=0');

	$refPage->assign('id', _('Admin-ID') . ': ');
	$refPage->assign('idx', $admin['user_id']);

	$refPage->assign('name', _('Name') . ': ');
	$refPage->assign('namex', $admin['user_name']);

	$refPage->assign('textx', $admin['user_text']);

	$refPage->assign('active', _('Activ') . ': ');
	if ($admin['user_active'] === 0)
	{
		$refPage->assign('isActive', '');
	}
	else
	{
		$refPage->assign('isActive', 'checked');
	}

	$refPage->assign('level', _('Adminlevel') . ': ');
	$levelx = '<select size="1" name="levelx" id="levelx">' . '<option value="0" ';
	if ($admin['user_level'] == 0)
		$levelx .= 'selected=\'selected\'';

	$levelx .= '>' . '0 - ' . _('Locked') . '</option>' . '<option value="1"';
	if ($admin['user_level'] == 1)
		$levelx .= 'selected=\'selected\'';

	$levelx .= '>' . '1 - ' . _('Administrator') . '</option>' . '<option value="2"';
	if ($admin['user_level'] == 2)
		$levelx .= 'selected=\'selected\'';

	$levelx .= '>' . '2 - ' . _('Manager') . '</option>' . '<option value="3"';
	if ($admin['user_level'] == 3)
		$levelx .= 'selected=\'selected\'';

	$levelx .= '>' . '3 - ' . _('Editor') . '</option>' . '<option value="4"';
	if ($admin['user_level'] == 4)
		$levelx .= 'selected=\'selected\'';

	$levelx .= '>' . '4 - ' . _('User') . '</option>' . '</select>';
	$refPage->assign('levelx', $levelx);

	$refPage->assign('mail', _('Email') . ': ');
	$refPage->assign('mailx', $admin['user_mail']);

	$refPage->assign('connection', _('Last connection data') . ': ');
	$refPage->assign('connectionx',
		$admin['user_lastonline'] . '<br>' . $admin['user_ip'] . '<br>' .
		$admin['user_info'] . '<br>' . _('Loginerrors') . ': ' . $admin['user_errors']);

	$refPage->assign('btnSave',
		'<input type="hidden" name="passwordx" value="' . $admin['user_password'] . '">' .
		'<input type="hidden" name="idxx" value="' . $admin['user_id'] . '">' .
		'<input type="hidden" name="secureidx" value="' . $admin['user_secureid'] . '">' .
		'<input type="submit" name="submit" id="save" value="' . _('Save') . '" />');
	$refPage->assign('btnAbort',
		'<input type="submit" name="submit" id="abort" value="' . _('Cancel') . '" />');
	$refPage->assign('btnPassword',
		'<input type="submit" name="submit" id="password" value="' .
		_('New password') . '" />');

	$refPage->addtpl('content', '/' . $page . '/' . $subpage . '.editor.tpl.php');
	$refPage->assign('scripts',
		'<script type="text/javascript" src="' .
		'module/ckeditor/ckeditor.js"></script>');
}
?>